using System;
using System.ComponentModel;
using System.Collections.ObjectModel;

namespace PyBindingTest
{
    public class MainPresenter : INotifyPropertyChanged
    {
        private string _name;
        public string Name
        {
            get { return _name; }
            set
            {
                if (value == _name)
                    return;

                _name = value;
                OnPropertyChanged("Name");
            }
        }

        private ObservableCollection<Person> _people;
        public ObservableCollection<Person> People
        {
            get { return _people; }
            set
            {
                if (value == _people)
                    return;

                _people = value;
                OnPropertyChanged("People");
            }
        }

        /// <summary>
        /// Initializes a new instance of the MainPresenter class.
        /// </summary>
        public MainPresenter()
        {
            this.People = new ObservableCollection<Person>() 
				            { 
                                //new Person(){ Name= "One", Age=20},
                                //new Person(){ Name= "Two", Age=30},
                                //new Person(){ Name= "Three", Age=40},
				            };

            for (int i = 0; i < 400; i++)
            {
                this.People.Add(new Person() { Name = i.ToString(), Age = i });
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged == null)
                return;

            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

    }
}